package com.chalmerslosers.utils;


import java.util.Date;

import com.liferay.portal.model.User;



public final class Post {
    
    
    private Long id;

    
    private User author;
    
    
    private String anonAuthor;

    
    private String content;

	private Date date;
    
    
    private Date modifiedDate;
    
    
    private Long parentId;

    
    private Long topParentId;
    
    public Post(){
    	
    }
    public Post(long id, User author, String content, Date date, Long parentId, Long topParentId) {
        this.id = id;
    	this.author = author;
        this.anonAuthor = null;
        this.content = content;
        this.date = date;
        this.parentId = parentId;
        this.topParentId = topParentId;
        this.modifiedDate = date;
    }
    
    public Post(long id, String author, String content, Date date, Long parentId, Long topParentId) {
    	this.id = id;
        this.author = null;
        this.anonAuthor = author;
        this.content = content;
        this.date = date;
        this.parentId = parentId;
        this.topParentId = topParentId;
        this.modifiedDate = date;
    }

    public Long getId() {
        return id;
    }
    
    public String getContent() {
//        String sanitizedContent = content.trim().
//                                                                replaceAll("<", "&lt;").
//                                                                replaceAll(">", "&gt;").
//                                                                replaceAll("\n", "<br/>");
//        return sanitizedContent;
    	return content;
    }

    public Date getDate() {
        return date;
    }    

        public Long getParentId(){
                return parentId;
    }
    
    public Long getTopParentId(){
        return topParentId;
    }   
    
    public void setModifiedDate( Date date ){
        this.modifiedDate = date;
    }    
    
    
    public void setContent(String content) {
		this.content = content;
	}
	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
	public void setTopParentId(Long topParentId) {
		this.topParentId = topParentId;
	}
	public User getAuthor() {
		return author;
	}
	public void setAuthor(User author) {
		this.author = author;
	}
	public String getAnonAuthor() {
		return anonAuthor;
	}
	public void setAnonAuthor(String anonAuthor) {
		this.anonAuthor = anonAuthor;
	}
	
    public String getAuthorNickName(){
        if ( author != null ){
                return author.getFirstName();
        } else if ( anonAuthor != null){
                return anonAuthor;
        }
        else{
                return "Anonymous author";
        }
    }
	public Date getModifiedDate() {
		return modifiedDate;
	}

	
	
   
}
